unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RzEdit, ExtCtrls, Mask, RzLabel, RzButton,Dialog_View,
  SQLServerUniProvider, UniProvider, OracleUniProvider,Class_KzThrad,
  RzStatus, RzPanel, DB, DBAccess, Uni;

type
  TForm1 = class(TDialogView)
    Panel1: TPanel;
    Memo_TEST: TRzMemo;
    RzLabel1: TRzLabel;
    Labl_1: TRzLabel;
    Labl_2: TRzLabel;
    Labl_3: TRzLabel;
    Edit_SRVRNAME: TRzEdit;
    Edit_DATABASE: TRzEdit;
    Edit_USERNAME: TRzEdit;
    Edit_PASSWORD: TRzEdit;
    Btnx_TEST: TRzButton;
    OracleUniProvider1: TOracleUniProvider;
    SQLServerUniProvider1: TSQLServerUniProvider;
    RzStatusBar1: TRzStatusBar;
    Prog_View: TRzProgressStatus;
    UniConnection1: TUniConnection;
    procedure Btnx_TESTClick(Sender: TObject);
  private
  protected
    procedure SetInitialize;override;
    procedure SetCommParams;override;
    procedure SetGridParams;override;
    procedure SetComboItems;override;
    procedure TryFreeAndNil;override;
  public
    procedure CallThradTestUNI;
  public
    //for tkzthrad
    procedure OnKzThradGetMaxProgress(Sender: TObject;AMaxProgress:Integer);
    procedure OnKzThradGetOneProgress(Sender: TObject;AOneProgress:Integer);
    procedure OnKzThradGetTxtProgress(Sender: TObject;ATxtProgress:string);
    procedure OnKzThradGetMsgProgress(Sender: TObject;AMsgProgress:string;AVarProgress:array of Variant);
    procedure OnTerminate(Sender:TObject);
  end;

var
  Form1: TForm1;

implementation

uses
  Thrad_TestUNI;

{$R *.dfm}

{ TForm1 }

procedure TForm1.CallThradTestUNI;
begin

end;

procedure TForm1.OnKzThradGetMaxProgress(Sender: TObject;
  AMaxProgress: Integer);
begin
  Prog_View.TotalParts:=AMaxProgress;
end;

procedure TForm1.OnKzThradGetMsgProgress(Sender: TObject;
  AMsgProgress: string; AVarProgress: array of Variant);
var
  I:Integer;
  S:string;
begin
  if AMsgProgress='START' then
  begin
    Btnx_TEST.Enabled:=False;
  end else
  if AMsgProgress='ENDED' then
  begin
    Btnx_TEST.Enabled:=True;
  end else
  if AMsgProgress=Class_KzThrad.CONST_THRAD_STAT_TRUE then
  begin
    I:=AVarProgress[0];
    Self.Memo_TEST.Lines.Add(Format('TRUE:%D',[I]));
  end else
  if AMsgProgress=Class_KzThrad.CONST_THRAD_STAT_EROR then 
  begin
    I:=AVarProgress[0];
    S:=AVarProgress[1];
    Self.Memo_TEST.Lines.Add(Format('TRUE:%D:%S',[I,S]));
  end;
end;

procedure TForm1.OnKzThradGetOneProgress(Sender: TObject;
  AOneProgress: Integer);
begin
  Prog_View.PartsComplete:=AOneProgress;
end;

procedure TForm1.OnKzThradGetTxtProgress(Sender: TObject;
  ATxtProgress: string);
begin

end;

procedure TForm1.OnTerminate(Sender: TObject);
begin

end;

procedure TForm1.SetComboItems;
begin
  inherited;

end;

procedure TForm1.SetCommParams;
begin
  inherited;
  Edit_USERNAME.Text:='sa';
  Edit_PASSWORD.Text:='sa';
end;

procedure TForm1.SetGridParams;
begin
  inherited;

end;

procedure TForm1.SetInitialize;
begin
  inherited;

end;

procedure TForm1.TryFreeAndNil;
begin
  inherited;

end;

procedure TForm1.Btnx_TESTClick(Sender: TObject);
var
  ThradA:TThradTestUNI;
begin
  ThradA:=TThradTestUNI.Create(True);

  ThradA.FSRVRNAME:=Trim(Edit_SRVRNAME.Text);
  ThradA.FDATABASE:=Trim(Edit_DATABASE.Text);
  ThradA.FUSERNAME:=Trim(Edit_USERNAME.Text);
  ThradA.FPASSWORD:=Trim(Edit_PASSWORD.Text);
  
  ThradA.OnKzThradGetMaxProgress:=OnKzThradGetMaxProgress;
  ThradA.OnKzThradGetOneProgress:=OnKzThradGetOneProgress;
  ThradA.OnKzThradGetTxtProgress:=OnKzThradGetTxtProgress;

  ThradA.OnKzThradGetMsgProgress:=OnKzThradGetMsgProgress;
  ThradA.OnTerminate            :=OnTerminate;
  ThradA.FreeOnTerminate        :=True; 

  ThradA.Resume; 
end;

end.
